/**
* @author Meng Zhang
**/

#pragma once
#include <set>
#include "../Helper/HelperMarcos.h"
#include "../Facade/IPluginFacade.h"

class BufferBase;
class BufferListener;
class TextBufferFactory;
class TextBuffer;
struct BufferCreateInfo;
class CTextBufferView;

class BufferController {
	DECLARE_SINGLETON(BufferController)
public:
	//void RegisterBuffer(BufferBase* buffer);
	TextBuffer* CreateTextBuffer(BufferCreateInfo *info = NULL);
	CTextBufferView* CreateTextBufferView();
	TextBuffer* GetEmptyBuffer();
	
	void SaveFile(TextBuffer* buffer);
	bool EnsureSave(TextBuffer* buffer);
	void RemoveBuffer(BufferBase* buffer);
	void VirtualSaveBuffer(TextBuffer *buffer);

	bool TryDestroy();//return true if destroy success
	std::vector<BHND> GetTextBufferList();
	TextBuffer* GetTextBufferByHandle(BHND bhnd);
private:
	//std::set<BufferBase*> buffers;
	TextBufferFactory* textBufferFactory;
	//bool EnsureSaveModify();
};